﻿///<reference path="_moduleReferences.ts" />

module ScrambledEggs.Modules {
    export class Hat {
        constructor(public Sign: string, public Description: string) {
        }
    }

    export class HatEvent implements IModule {
        private _onUpdate: () => void;

        constructor() {
        }

        initialize(gameState: GameStateProvider, onUpdate: () => void ) {
            this._onUpdate = onUpdate;
        }

        update(gameState: GameStateProvider, triggerqource: IModule): void {
            var me = this;

            if (gameState.State.Phase == GamePhase.YoungAdult && gameState.State.Hat == "") {

                var setHat = function (hat: string) {
                    gameState.State.Hat = hat;
                    gameState.State.Message = "You don your hat and look upon yourself in the mirror with pride. <strong>" + gameState.State.Hat + "</strong>", "Continue";
                    me._onUpdate();
                }

                var showHats = function () {
                    Utility.General.OptionBox("The box opens. Choose your <strong>hat</strong> wisely!",
                        { Content: "Cowboy Hat: <strong>@</strong>", Action: function () { setHat("@"); } },
                        { Content: "Baseball Cap: <strong>ô</strong>", Action: function () { setHat("ô"); } },
                        { Content: "Bowler Hat: <strong>o</strong>", Action: function () { setHat("o"); } },
                        { Content: "Sombrero: <strong>ⓞ</strong>", Action: function () { setHat("ⓞ"); } },
                        { Content: "Propellor Hat: <strong>Ø</strong>", Action: function () { setHat("Ø"); } },
                        { Content: "Coonskin Cap: <strong>Ϙ</strong>", Action: function () { setHat("Ϙ"); } }
                    );
                };

                Utility.General.InfoBox("Your " + (gameState.State.Gender == Gender.Male ? "father" : "mother") + " approaches", "...", function () {
                    Utility.General.InfoBox("\"The time has come!\"", "Time for what?!", function () {
                        Utility.General.InfoBox("\"Time to make one of the most important decisions of your life, my " + (gameState.State.Gender == Gender.Male ? "boy.\"" : "girl.\""), "Huh...?", function () {
                            Utility.General.YesNoBox("\"I have here a box, containing four <strong>hats</strong>.\"<br /><br />\"You may choose <strong>only one hat</strong>.\"<br /><br />\"Whichever <strong>hat</strong> you choose, will be bound to you for the rest of your life.\"<br /><br /><br /><br />Are you ready to make this decision right now?",
                                showHats,
                                function () {
                                    Utility.General.InfoBox("Too bad!", "...", showHats);
                                }
                            );
                        });
                    });
                });
            }
        }
    }
}